home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
util1
/
yk211src.lha
/
Yak_2.11_Src
/
Prefs
/
GadTools
/
Misc_window.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-16
|
9KB
|
336 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Martin W Scott and Gaël Marziou
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <intuition/intuitionbase.h>
#include <libraries/gadtools.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/gadtools.h>
#include <proto/wb.h>
#include <string.h>
#include "yak.h"
#include "version.h"
#include "hotkey_types.h"
#include "gui.h"
#include "Misc_Window.h"
#include "Settings.h"
#include "yak_locale_strings.h"
extern struct Catalog *Catalog;
extern struct DosLibrary *DOSBase;
extern LONG (*HandleIDCMP)(void);
struct Window *MiscWnd = NULL;
struct Gadget *MiscGList = NULL;
struct Gadget *MiscGadgets[Misc_CNT];
UWORD MiscWidth = 440;
UWORD MiscHeight = 95;
UBYTE *MiscWdt = NULL;
BOOL MiscWdi = FALSE;
struct AppWindow *MiscAppWin; /* AppWindow pointer */
IMPORT struct MsgPort *AppMsgPort;
/* Online help system */
IMPORT void ShowYakHelp(char *, char *);
IMPORT void CloseYakHelp(void);
IMPORT char *PrefsHelp;
UWORD MiscGTypes[] = {
SLIDER_KIND,
BUTTON_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND
};
struct NewGadget MiscNGad[] = {
227, 4, 180, 11, NULL, NULL, GD_ClickVol, PLACETEXT_LEFT, NULL, CLICKVOLUME_STRING,
170, 79, 100, 13, NULL, NULL, GD_Return2, PLACETEXT_IN, NULL, OK_STRING,
227, 25, 26, 11, NULL, NULL, GD_BlackBorderCheck, PLACETEXT_RIGHT, NULL, BLACK_BORDER,
7, 25, 26, 11, NULL, NULL, GD_WildStarCheck , PLACETEXT_RIGHT, NULL, WILD_STAR_STRING,
7, 37, 26, 11, NULL, NULL, GD_NoClickCheck , PLACETEXT_RIGHT, NULL, NOCLICK_STRING,
227, 49, 26, 11, NULL, NULL, GD_UnixDirsCheck , PLACETEXT_RIGHT, NULL, UNIXDIRS_STRING,
7, 49, 26, 11, NULL, NULL, GD_MMBShiftCheck, PLACETEXT_RIGHT, NULL, MMB_SHIFT_STRING,
227, 61, 26, 11, NULL, NULL, GD_SlashDirCheck, PLACETEXT_RIGHT, NULL, SLASHDIR_STRING,
7, 61, 26, 11, NULL, NULL, GD_FullWorkbenchCheck, PLACETEXT_RIGHT, NULL, FULL_WORKBENCH_STRING,
227, 37, 26, 11, NULL, NULL, GD_CapShiftCheck, PLACETEXT_RIGHT, NULL, CAPSHIFT_STRING
};
ULONG MiscGTags[] = {
(GTSL_Max), 64, (GTSL_MaxLevelLen), 4, (GTSL_LevelFormat), (ULONG)"%2ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE),
(GTCB_Scaled), TRUE, (TAG_DONE)
};
VOID
MiscRender()
{
UWORD Width, Height;
ComputeFont(MiscWidth,MiscHeight);
Width = ComputeX( MiscWidth );
Height= ComputeY(76);
DrawThinBevelBox( Scr, MiscWnd->RPort, OffX,
OffY,
Width,
Height,
FALSE );
DrawThinBevelBox( Scr, MiscWnd->RPort, OffX,
OffY + Height,
Width,
ComputeY(MiscHeight) - Height,
FALSE );
}
int
OpenMiscWindow()
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc,tc;
WORD wleft=WindowLeft, wtop=WindowTop;
UWORD ww, wh;
ComputeFont(MiscWidth,MiscHeight);
ww = OffX + ComputeX(MiscWidth) + Scr->WBorRight;
wh = OffY + ComputeY(MiscHeight) + Scr->WBorBottom;
SetUpWindowCoordinates(ww, wh, &wleft, &wtop);
if (! (g = CreateContext(&MiscGList)))
return(1L);
for(lc = 0,tc = 0; lc < Misc_CNT; lc++)
{
CopyMem((char *)&MiscNGad[ lc ],(char *)&ng,(long)sizeof(struct NewGadget));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX +ComputeX(ng.ng_LeftEdge);
ng.ng_TopEdge = OffY +ComputeY(ng.ng_TopEdge);
ng.ng_Width = ComputeX(ng.ng_Width);
ng.ng_Height = ComputeY(ng.ng_Height);
MiscGadgets[ lc ] = g = CreateGadgetA((ULONG)MiscGTypes[ lc ],g,&ng,(struct TagItem *) &MiscGTags[ tc ]);
while(MiscGTags[ tc ])
tc += 2;
tc++;
if (NOT g)
return(2L);
}
if (NOT (MiscWnd = OpenWindowTags(NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww,
WA_Height, wh,
WA_IDCMP, LISTVIEWIDCMP|STRINGIDCMP|CYCLEIDCMP|BUTTONIDCMP|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW|IDCMP_RAWKEY,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH,
WA_Gadgets, MiscGList,
WA_Title, MiscWdt,
WA_ScreenTitle, getString(COPYRIGHT_STRING),
WA_PubScreen, Scr,
WA_PubScreenName,PubScreenName,
TAG_DONE)))
return(4L);
MiscAppWin = AddAppWindowA(0, 0, MiscWnd, AppMsgPort, NULL);
GT_RefreshWindow(MiscWnd,NULL);
MiscRender();
return(0L);
}
VOID
CloseMiscWindow()
{
CloseOneWindow(MiscWnd,NULL,MiscGList,MiscAppWin);
MiscWnd = NULL;
}
/* initialise all gadgets of Misc window */
static void
InitMiscGadgets(void)
{
InitToggleGadgets(MISC_WINDOW);
InitWindowGadget(GDX_SlashDirCheck, GA_Disabled, !unixdirs, MISC_WINDOW);
InitWindowGadget(GDX_ClickVol, GTSL_Level, click_volume, MISC_WINDOW);
}
/* handle Misc window events */
LONG
HandleMiscIDCMP(void)
{
struct IntuiMessage *msg;
struct Gadget *gadget;
ULONG class;
UWORD code;
BOOL close=FALSE;
LONG ret=RET_OKAY;
while (!close && (msg = GT_GetIMsg(MiscWnd->UserPort)))
{
class = msg->Class;
code = msg->Code;
gadget = (struct Gadget *)msg->IAddress;
GT_ReplyIMsg(msg);
switch (class)
{
case GADGETUP:
case GADGETDOWN:
switch (gadget->GadgetID)
{
case GD_Return2:
CloseMiscWindow();
if (!ShowWindowID(ROOT_WINDOW))
ret= RET_QUIT;
close = TRUE;
break;
case GD_ClickVol:
click_volume = code;
break;
case GD_BlackBorderCheck:
blackborder ^= TRUE;
break;
case GD_WildStarCheck: /* toggle */
wildstar ^= TRUE;
break;
case GD_NoClickCheck: /* toggle */
noclick ^= TRUE;
break;
case GD_UnixDirsCheck: /* toggle */
unixdirs ^= TRUE;
InitWindowGadget(GDX_SlashDirCheck, GA_Disabled, !unixdirs, MISC_WINDOW);
break;
case GD_MMBShiftCheck: /* toggle */
mmbshift ^= TRUE;
break;
case GD_SlashDirCheck: /* toggle */
slashdir ^= TRUE;
break;
case GD_FullWorkbenchCheck: /* toggle */
fullworkbench ^= TRUE;
break;
case GD_CapShiftCheck: /* toggle */
capshift ^= TRUE;
break;
} /* switch (gadget->GadgetID) */
break;
case IDCMP_RAWKEY:
/* Help key pressed */
if (code == 95)
{
/* Display the node */
ShowYakHelp(PrefsHelp, "Miscellaneous");
}
break;
case REFRESHWINDOW:
GT_BeginRefresh(MiscWnd);
GT_EndRefresh(MiscWnd, TRUE);
break;
} /* switch (class) */
} /* while more messages */
return ret;
}
/* show our misc window */
BOOL
ShowMiscWindow(void)
{
if (!MiscWdi)
{
MiscWdi = TRUE;
MiscWdt = getString(MISCELLANEOUS_STRING);
LocalizeNGadLabels (Misc_CNT, MiscNGad);
}
if (!OpenMiscWindow()) /* like the name says... */
{
InitMiscGadgets();
wndsigflag = 1 << MiscWnd->UserPort->mp_SigBit;
curwin = MiscWnd;
curwinID = MISC_WINDOW;
HandleIDCMP = HandleMiscIDCMP;
return TRUE;
}
FreeGadgets(MiscGList);
CloseDownScreen();
curwin = NULL;
wndsigflag = 0L;
return FALSE;
}